﻿using System.Diagnostics.CodeAnalysis;

namespace Modules.Commander.Comparers;

internal class CommanderProjectComparer : IEqualityComparer<CommanderProject>
{
    public bool Equals(CommanderProject? x, CommanderProject? y)
    {
        if (x == null && y == null)
            return true;
        else if (x == null || y == null)
            return false;
        else if (x.CommanderId == y.CommanderId && x.ProjectId == y.ProjectId)
            return true;
        else
            return false;
    }

    public int GetHashCode([DisallowNull] CommanderProject obj)
    {
        return $"{obj.CommanderId}{obj.ProjectId}".GetHashCode();
    }
}
